<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="js/vue.js"></script>
    <script src="js/elementUI.js"></script>
    <script src="js/axios.js"></script>
    <link rel="stylesheet" href="css/elementUI.css">
</head>
<body>
<div id="app">
    <el-form ref="form" :model="form" label-width="80px">
        <el-form-item label="账号">
            <el-input v-model="form.username"></el-input>
        </el-form-item>
        <el-form-item label="密码">
            <el-input v-model="form.password"></el-input>
        </el-form-item>
        <el-form-item>
            <el-button type="primary" @click="login">登陆</el-button>
        </el-form-item>
    </el-form>
</div>
<script>
    new Vue({
        el:"#app",
        data:{
            form:{
                username:"",
                password:""
            }
        },
        methods:{
            login(){
                axios.post("/user/login",this.form).then(res=>{
                    if(res.data.code==0){
                        this.$message.error(res.data.msg);
                    }else{
                        if(res.data.data.roleName=='普通员工'){
                            location.href="task.html";
                        }
                        if(res.data.data.roleName=='领导'){
                            location.href="taskLeader.html";
                        }
                    }
                })
            }
        },
        created(){

        }
    })
</script>
</body>
</html>